<?php

/*

  Action	$3

  +1 Card
  +2 Actions
  At the start of Clean-up, if you have this and no more than one other Action card in play, you may put this on top of your deck.

 */

class WalledVillage extends Card implements iAction, iKingdom {

    public function __construct() {
        parent::__construct("Walled Village", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+2 Actions",
            "At the start of Clean-up, if you have this and no more than one other Action card in play, you may put this on top of your deck.");
    }

    public function play(Game $game, $isRealCard) {
        $game->addActions(2);
        $drawed_cards = $game->drawCards(1);
        ScreenDisplay::addScreenMessage($game, true, "get +2 actions  and draw " . nicePrint($drawed_cards), "get +2 actions and draws " . sizeof($drawed_cards) . " cards");
    }

    public function cleanup(Game $game) {
        $cards = $game->getPlayArea();
        $actions = 0;
        foreach ($cards as $card) {
            if ($card instanceof iAction) {
                $actions++;
            }
        }

        if ($actions < 3) {

            $options = array(new Option(1, "Yes"), new Option(2, "No"));
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Return walled village on top of the draw deck?");
            $answer = $output[0];
            if ($answer == "Yes") {
                $game->moveCardFromPileToPile($this, PlayArea, DrawPile);
                ScreenDisplay::addScreenMessage($game, true, "return ".  nicePrint($this)." on top of your deck ", "returns ". ScreenDisplay::$LMSG."  on top of his deck");
            } else {
                $game->moveCardFromPileToPile($this, PlayArea, DiscardPile);
                ScreenDisplay::addScreenMessage($game, true, "discrad ".  nicePrint($this), "discards ". ScreenDisplay::$LMSG);
            }
        }
        $game->cardActionFinished();
        return true;
    }

}

?>